1. Field of the Invention
The present invention relates generally to the implementation of Java(trademark) classes, and in particular, to a method for providing for persistence of Java(trademark) classes where the persistence semantics of the Java(trademark) classes may be orthogonal to the class definition.
2. Description of Related Art
It is well known in the art to use object-oriented programming techniques with relational database management systems, such as IBM""s Database 2 (DB2(trademark)) Universal Database (UDB(trademark)) relational database management system. Currently, there is a need to store objects in such a database, in order to provide persistence of the objects.
However, existing approaches for persistence of objects of a Java(trademark) class have required one of the following:
1. The Java(trademark) class implements the Serializable or Externalizable interfaces defined as part of the Java(trademark) language specification.
2. The Java(trademark) class implements the SQLData interface defined as part of the Java(trademark) Database Connectivity (JDBC) 2.0 Extensions, which is one of the standard Application Programming Interfaces (API) of the Java(trademark) Language Specification.
3. A special non-standard virtual machine execution environment which implements more than the standard Java(trademark) virtual machine (JVM) specification, which would be a model for xe2x80x9ctrue orthogonal persistencexe2x80x9d, where objects that are still xe2x80x9clivexe2x80x9d automatically survive without any code that explicitly instructs them to do so.
Using one of approaches (1) and (2) mentioned above is feasible when the user of the Java(trademark) class is also its author. In the real world, however, programmers often reuse general-purpose Java(trademark) classes that are distributed by third parties, and have neither the authority to modify such classes, nor the source code of the classes themselves. Even if the user can modify the Java(trademark) class, it is desirable to have persistence as a property that is independent of the class definition and usage, i.e., as an orthogonal property.
The xe2x80x9calmost idealxe2x80x9d situation of approach (3) above is infeasible because it requires a special non-standard execution environment that describes something more than the Java(trademark) language itself.
The problem of persistent programming languages has been a topic for research in the programming language community for the last 15 years. There have been various approaches proposed over the years, but they can all be placed in one of two categories:
1. The persistence semantics are tied into the definition of the programming language type, i.e., by implementing special interfaces or by inheriting such semantics from special superclasses. In the Java(trademark) case, this corresponds to approaches (1) and (2) mentioned above with regard to existing approaches. However, this does not provide the semantics of orthogonal persistence.
2. The underlying programming language is changed by building the semantics into the execution environment for interpretive languages or by training the compiler for compiled languages. In either situation, the result is semantics that will work only in very restricted cases. For the Java(trademark) language, this corresponds to approach (3) mentioned above with regard to existing approaches. With Java(trademark), it is absolutely necessary for the code to run in any standard Java(trademark) environment, and so this is infeasible.
Thus, there is a need in the art for new approaches for providing persistence for Java(trademark) objects.
To overcome the limitations in the prior art described above, and to overcome other limitations that will become apparent upon reading and understanding the present specification, the present invention discloses a method, apparatus, and article of manufacture for providing for persistence of Java(trademark) objects. A Java(trademark) object is instantiated from its corresponding Java(trademark) class definition and then loaded into a Java(trademark) virtual machine (JVM). The class definition corresponding to the Java(trademark) object can be derived using the Java(trademark) Reflection Application Programming Interface (API). Once the class definition is derived, it can be used to create a structured type in a relational database management system (RDBMS) that corresponds to the Java(trademark) class (where fields in the Java(trademark) class map to attributes in the structured type). The class definition can be used with the Java(trademark) Reflection API to inspect the contents of the Java(trademark) object. An instance of a structured type is then generated from the inspected contents of the Java(trademark) object, wherein the instance is stored in a column of a table of a relational database managed bathe RDBMS. As a result of these steps, the Java(trademark) object is persistently stored in the database, yet the persistence semantics for storing the object are not specified as part of the class definition of the object, which means that the persistence semantics are orthogonal to the class definition.
Various advantages and features of novelty, which characterize the invention, are pointed out with particularity i n the claims annexed hereto and form a part hereof. However, for a better understanding of the invention, its advantages, and the objects obtained by its use, reference should be made to the drawings which form a further part hereof, and to accompanying descriptive matter, in which there is illustrated and described specific examples of an apparatus in accordance with the invention.